﻿Chenxin.UI.userManager = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: 'service/userManage.ashx',
    createGrid: function() {
        return new Chenxin.UI.Pagination({
            actionUrl: this.actionUrl + '?op=Search',
            domId: 'page',
            pageSize: 10,
            data: {},
            render: function(data) {
                document.getElementById('userinfo_table').innerHTML = data;
            }
        });
    },
	createForm:function(){
        this.jqmUserManageAddForm = new Chenxin.UI.UserManageAddForm({
            scope:this,
            afterGetFormJson:function(json){
                json.CityId=json.divCity;
                json.CityName=this.jqmUserManageAddForm.comboList[0]._txt;
                json.CompanyId=json.divCompany;
                json.CompanyName=this.jqmUserManageAddForm.comboList[1]._txt;
                json.DepartId=json.divDepartId;
                json.DepartName=this.jqmUserManageAddForm.comboList[3]._txt;
                json.Sex=json.input_sex;
                json.IDType=json.divIDType;
                json.EmpLevel=json.divEmpLevel;
                json.Position=json.divEditPosition;
                json.Education=json.divEducation;

                delete json.divCity; 
                delete json.divCompany; 
                delete json.divBusinessDistrict; 
                delete json.divDepartId; 
                delete json.input_sex;
                delete json.divIDType; 
                delete json.divEmpLevel; 
                delete json.divEditPosition; 
                delete json.divEducation;
                
            }
            
        });
        this.jqmUserManageEditForm = new Chenxin.UI.UserManageEditForm({
            scope:this,
            afterGetFormJson:function(json){
                json.Education=json.edit_ed;
                json.IDType=json.edit_papers;
                json.Sex=json.editinput_sex;
                json.Validate=json.editValidate;
                delete json.edit_ed; 
                delete json.edit_papers; 
                delete json.editinput_sex; 
                delete json.editValidate;
            }
        });
        this.jqmUserChgPersonnelForm = new Chenxin.UI.UserChgPersonnelForm({
            scope:this,
            afterGetFormJson:function(json){
                json.DepartId=json.divDepartChgPer;
                json.DepartName=this.jqmUserChgPersonnelForm.comboList[3]._txt;
                json.TransTypeId=json.divTransTypeChgPer; 
                json.TransType=this.jqmUserChgPersonnelForm.comboList[4]._txt;
                json.Level=json.divEmpLevelChgPer; 
                json.Position=json.divEditPositionChgPer; 
                
                delete json.divDepartChgPer; 
                delete json.divTransTypeChgPer; 
                delete json.divEmpLevelChgPer; 
                delete json.divEditPositionChgPer;
                delete json.UserCode;
                delete json.UserName;
                delete json.divCityChgPer;
                delete json.divCompanyChgPer; 
                delete json.divBusinessDistrictChgPer; 
            }
        });
        this.jqmUserTermsForm = new Chenxin.UI.UserTermsForm({
            scope:this
        });
        this.jqmUserVirtualForm = new Chenxin.UI.UserVirtualForm({
            scope:this,
            afterGetFormJson:function(json){
                json.CityId=json.divCityUserVirtual;
                json.CityName=this.jqmUserVirtualForm.comboList[0]._txt;
                json.CompanyId=json.divCompanyUserVirtual;
                json.CompanyName=this.jqmUserVirtualForm.comboList[1]._txt;
                json.DepartId=json.divDepartUserVirtual;
                json.DepartName=this.jqmUserVirtualForm.comboList[3]._txt;

                delete json.divCityUserVirtual; 
                delete json.divCompanyUserVirtual; 
                delete json.divBusinessDistrictUserVirtual; 
                delete json.divDepartUserVirtual; 
            }
        });
	},
    cancle: function() {

    },
    initEvent: function() {
        var _this=this;
        
        $('.tr_houselist').live('click', function() {
            $('.tr_houselist,.selected_orgbgcolor').each(function() {
                $(this).removeClass('selected_orgbgcolor');
            });

            $(this).toggleClass('selected_orgbgcolor');
            $("#hidSelectedUser").val(this.id);
        });
        $('.tr_houselist').live('mouseover', function() {
            $(this).toggleClass('orgbgcolor');
        });
        $('.tr_houselist').live('mouseout', function() {
            $(this).toggleClass('orgbgcolor');
        });
        
        //添加员工
        $('#aAddUser').live('click',function(){
            _this.jqmUserManageAddForm.reset();
            _this.jqmUserManageAddForm.show();
        });
        
        //编辑员工
        $("#aEditBaseInfo").live("click", function() {

            //被选择的行
            if ($("#hidSelectedUser").val() == "") {
                alert("请选择一行后进行编辑");
                return;
            }

            var rowdata = _this.getdatabyrowid();
            if (rowdata.Status == "-1") {
                alert("该员工已离职，不可编辑信息");
                return;
            }

            Chenxin.ajax({
				type: "post",
				dataType: "json",
				url: _this.actionUrl,
				data: {op:"GetBaseInfo",UserId:$("#hidSelectedUser").val()},
				onSuccess: function(data) {
				    if (data.BirthDay != null) data.BirthDay = data.BirthDay.substr(0,10);//更改生日日期格式
				    data.edit_ed=data.Education;//绑定学历
				    data.edit_papers=data.IDType;//绑定身份证
				    _this.jqmUserManageEditForm.currentModel=data;
				    _this.jqmUserManageEditForm.fitData(data);
				    if (data.Sex == 0) $("#editinput_sex0").attr("checked", true);	
				    if (data.Sex == 1) $("#editinput_sex1").attr("checked", true);
                    _this.jqmUserManageEditForm.show();

                }
            });
            
        });
        
        //档案查看        
        $("#aArchives").live("click", function() {
            if ($("#hidSelectedUser").val() == "") {
                alert("请选择一行后查看档案");
                return;
            }
            window.open("PersonnelFile.aspx?userid=" + $("#hidSelectedUser").val());
        });
        
        //人事变动
        $("#aChgPersonnel").live("click", function() {
            //被选择的行
            if ($("#hidSelectedUser").val() == "") {
                alert("请选择一行后进行编辑");
                return;
            }
            
            var rowdata = _this.getdatabyrowid();
            if (rowdata.Status == "-1") {
                alert("该员工已离职，不可编辑信息");
                return;
            }
            
            
            $("#ChgUserID").val($("#hidSelectedUser").val());
            $("#txtUserCodeChgPer").val(rowdata.UserCode);
            $("#txtUserNameChgPer").val(rowdata.UserName);
            $("#txtDepartNameChgPer").val(rowdata.DepartName);
            
            _this.jqmUserChgPersonnelForm.show();
            
        });
        
        //职权范围变更
        $("#aEditScope").live("click", function() {
            if ($("#hidSelectedUser").val() == "") {
                alert("请选择一行后查看档案");
                return;
            }
            var rowdata = _this.getdatabyrowid();
            if (rowdata.Status == "-1") {
                alert("该员工已离职，不可编辑信息");
                return;
            }

            $("#div_TermsShow").hide();
            $("#btn_addUserTerms").hide();
            $("#btn_addshowUserTerms").show();

            $("#TermsUserID").val($("#hidSelectedUser").val());
            $("#txtUserCodeUserTerms").val(rowdata.UserCode);
            $("#txtUserNameUserTerms").val(rowdata.UserName);
            _this.jqmUserTermsForm.show();
            
            Chenxin.ajax({
				type: "post",
				dataType: "json",
				url: _this.actionUrl,
				data: {op:"GetCount",stype:"terms",UserId:$("#hidSelectedUser").val()},
				onSuccess: function(data) {
                    alert(data);
                }
            });

        });
        
        //虚账号
        $("#aAddVirtual").live("click", function() {
            _this.jqmUserVirtualForm.reset();
            _this.jqmUserVirtualForm.show();
        });
        
    },

    createSearch: function() {
        return new Chenxin.UI.userManagerSearch({
            scope: this
        });
    },
    getdatabyrowid:function(){
        var rowdata = {};
        $(".selected_orgbgcolor td").each(function() {
            var colname = $(this).attr("name");
            rowdata[colname] = $(this).text();
        });
        return rowdata;
	},
    initComponent: function() {
        Chenxin.UI.userManager.superclass.initComponent.call(this);
    }
});


/**
*查询面板
*/
Chenxin.UI.userManagerSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'house_search',
    initEvent: function() {
        var _this = this;


        //生日模式
        $("#aTypeBorn").live("click", function() {
            if ($("#searchstr").val().length < 1)
                var data = {};
            else
                var data = eval("(" + $("#searchstr").val() + ")");
            $("#showtype").val("2");
            data.ShowType = "2";
            _this.scope.reloadGrid(data);
            $("#hidSelectedUser").val("");
        });

        //详细模式
        $("#aTypePersonnel").live("click", function() {
            if ($("#searchstr").val().length < 1)
                var data = {};
            else
                var data = eval("(" + $("#searchstr").val() + ")");
            $("#showtype").val("3");
            data.ShowType = "3";
            _this.scope.reloadGrid(data);
            $("#hidSelectedUser").val("");
        });

        //简单模式
        $("#aTypeSimple").live("click", function() {
            if ($("#searchstr").val().length < 1)
                var data = {};
            else
                var data = eval("(" + $("#searchstr").val() + ")");
            $("#showtype").val("1");
            data.ShowType = "1";
            _this.scope.reloadGrid(data);
            $("#hidSelectedUser").val("");
        });

        //查询按钮事件
        $('#btSreachUserInfo').live("click",function() {
        //条件
        var strCondition = $("#txtCondition").val();
        //工号
        var strUserCode = $("#txtUserCode").val();
        //状态
        var strStatus = selStatus.getValue();
        //到职时间（开始）
        var strComeDateFrom = $("#txtComeDateFrom").val();
        //到职时间（结束）
        var strComeDateTo = $("#txtComeDateTo").val();
        //合同时间（开始）
        var strContractDateFrom = $("#txtContractDateFrom").val();
        //合同时间（结束）
        var strContractDateTo = $("#txtContractDateTo").val();
        //离职时间（开始）
        var strLeaveDateFrom = $("#txtLeaveDateFrom").val();
        //离职时间（结束）
        var strLeaveDateTo = $("#txtLeaveDateTo").val();
        //身份证
        var strIDNo = $("#txtIDNo_s").val();
        //角色
        var strRoleId = selRole.getValue();
        //职位
        var strPosition = selPosition.getValue();
        //虚账号
        var strIsVirtual = selIsVirtual.getValue();

        var strConditionId = $("#hidConditionId").val();
        var strConditionType = $("#hidConditionType").val();

        //参数列表
        var strParams = {};

        strParams.Condition = strCondition;
        strParams.UserCode = strUserCode;
        strParams.Status = strStatus;
        strParams.ComeDateFrom = strComeDateFrom;
        strParams.ComeDateTo = strComeDateTo;
        strParams.ContractDateFrom = strContractDateFrom;
        strParams.ContractDateTo = strContractDateTo;
        strParams.LeaveDateFrom = strLeaveDateFrom;
        strParams.LeaveDateTo = strLeaveDateTo;
        strParams.IDNo = strIDNo;
        strParams.RoleId = strRoleId;
        strParams.Position = encodeURIComponent(strPosition);
        strParams.ConditionId = strConditionId;
        strParams.ConditionType = strConditionType;
        strParams.IsVirtual = strIsVirtual;
        strParams.ShowType = $("#showtype").val();

        strParams.cityid = favorMgr.search.combl.city.getValue() == "请选择" ? "" : favorMgr.search.combl.city.getValue();
        strParams.companyid = favorMgr.search.combl.company.getValue() == "请选择" ? "" : favorMgr.search.combl.company.getValue();
        strParams.areaid = favorMgr.search.combl.businessDistrict.getValue() == "请选择" ? "" : favorMgr.search.combl.businessDistrict.getValue();
        strParams.departid = favorMgr.search.combl.departs.getValue() == "请选择" ? "" : favorMgr.search.combl.departs.getValue();
        strParams.userid = favorMgr.search.combl.emp.getValue() == "请选择" ? "" : favorMgr.search.combl.emp.getValue();

        $("#searchstr").val(strParams.toString());
        $("#hidSelectedUser").val("");
            _this.scope.reloadGrid(strParams);
        });

    },
    createComboList: function() {
        this.combl = new Chenxin.UI.StructComboList();
        var structs = this.combl.comboList;

        //状态下拉框属性
        var cmbStatus = new Chenxin.UI.Combo({
            containerId: '#divStatus',
            tbxWidth: 45,
            items: comboCommon.UserStatusType
        });

        //角色
        var cmbRole = new Chenxin.UI.Combo({
            containerId: '#divRole',
            tbxWidth: 45,
            actionUrl: 'service/selector2.ashx',
            param: "city=<%= CurrentUserInfo.CityId%>&type=role",
            autoLoad: false
        });

        //职务
        var cmbPosition = new Chenxin.UI.Combo({
            containerId: '#divPosition',
            tbxWidth: 45,
            actionUrl: 'service/selector2.ashx',
            param: "city=<%= CurrentUserInfo.CityId%>&type=datadic&key=System.Position",
            autoLoad: false
        });

        //职级
        var cmbEmpLevel = new Chenxin.UI.Combo({
            containerId: '#divPosition',
            tbxWidth: 45,
            actionUrl: 'service/selector2.ashx',
            param: "city=<%= CurrentUserInfo.CityId%>&type=datadic&key=System.EmpLevel",
            autoLoad: false
        });

        //虚帐号
        var cmbIsVirtual = new Chenxin.UI.Combo({
            containerId: '#divIsVirtual',
            tbxWidth: 45,
            items: comboCommon.IsVirtual
        });
        return [structs, cmbStatus, cmbRole, cmbPosition, cmbIsVirtual];
    },
    initComponent: function() {
        Chenxin.UI.userManagerSearch.superclass.initComponent.call(this);
    }
});



$(document).ready(function() {
    var favorMgr = new Chenxin.UI.userManager();

    //添加菜单点中的样式
    // $("#mynav4").addClass("menu_on");

    //角色下拉列表框
    var selRole;
    //职务下拉列表框
    var selPosition;
    //状态下拉列表框
    var selStatus;
    //性别
    var selSex;
    //用户类型
    var selUserType;
    //证件类型
    var selIDType;
    //城市
    var selCity;
    //公司
    var selCompany = "";
    //教育程度
    var selEducation;
    //所属部门
    var selDepart;
    //职务
    var selEditPosition;
    //职级
    var selEmpLevel;
    //虚账号
    var selIsVirtual;


    /*add by tianno 2010-4-2*/
    //教育（编辑）
    var selEd_edit;
    //证件类型（编辑）
    var selPapers;

    //城市（人事变动）
    var selCity_chg;
    //公司（人事变动）
    var selCompany_chg = "";
    //部门（人事变动）
    var selDepart_chg;
    //变动类型（人事变动）
    var chgtype;
    //变动职务（人事变动）
    var chgPosition;
    //变动职级（人事变动）
    var chgLevel;

    //城市（职权）
    var selCity_terms;
    //公司（职权）
    var selCompany_terms;
    //部门（职权）
    var selDepart_terms;
    //职权（职权）
    var selTerms;

    //城市（虚账号）
    var selCity_Virtual;
    //公司（虚账号）
    var selCompany_Virtual;
    //部门（虚账号）
    var selDepart_Virtual;

    //职权-查询（职权职务）
    var selTerms_s;
    //职权-新增（职权职务）
    var selTerms_a;
    //公司-查询（职权职务）
    var selCompany_s;
    //公司-新增（职权职务）
    var selCompany_a;





    $.ajax({
        type: "POST",
        url: "service/userManage.ashx?op=GetShowContent",
        dataType: "Json",
        success: function(strRet) {
            //回传数据
            var jsonRet = eval("(" + strRet + ")");
            //执行结果的判断
            if (jsonRet.RetFlg == "SUCCESS") {

                //Data属性值
                var strRetData = jsonRet.Data;
                //分割
                var lsRetData = strRetData.split("@");
                //                    //操作内容的显示
                //                    $("#content").html(lsRetData[0]);
                //角色下拉框属性
                var optRole = {
                    containerId: '#divRole',
                    items: eval("([" + lsRetData[1] + "])"),
                    defVal: '0',
                    showMode: 'single'
                };
                selRole = new Selector(optRole);
                //职务下拉框属性
                var optPosition = {
                    containerId: '#divPosition',
                    items: eval("([" + lsRetData[4] + "])"),
                    //                        items: [{ txt: '请选择', val: '0' },
                    //                                { txt: '店长', val: '1' },
                    //                                { txt: '部长', val: '2' },
                    //                                { txt: '司机', val: '3' }],
                    defVal: '0',
                    colNum: '4',
                    showMode: 'single'
                };
                selPosition = new Selector(optPosition);

                //职务下拉框属性(人事变动)
                var optPosition_chg = {
                    containerId: '#chg_divzw',
                    items: eval("([" + lsRetData[4] + "])"),
                    defVal: '0',
                    colNum: '4',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                chgPosition = new Selector(optPosition_chg);

                //状态下拉框属性
                var optStatus = {
                    containerId: '#divStatus',
                    items: [{ txt: '全部', val: '0' },
                                { txt: '在职', val: '1' },
                                { txt: '离职', val: '-1'}],
                    defVal: '0',
                    showMode: 'single'
                };
                selStatus = new Selector(optStatus);

                //虚账号下拉框属性
                var optIsVirtual = {
                    containerId: '#divIsVirtual',
                    items: [{ txt: '否', val: '0' },
                                { txt: '是', val: '1'}],
                    defVal: '0',
                    showMode: 'single'
                };
                selIsVirtual = new Selector(optIsVirtual);

                //                    //取得一览数据
                //                    $("#jqGridBirthday").jqGrid({
                //                        url: 'service/userManage.ashx?op=Search',
                //                        datatype: "json",
                //                        width: 750,
                //                        height: 600,
                //                        colNames: ['工号', '姓名', '部门', '性别', '出生日期', '年龄', '学历', '职称', '职级', '身份证号', '到职日期', '合同订起', '合同订结', '公积金账号', '角色', '状态'],
                //                        colModel: [{ name: 'UserCode', index: 'UserCode', width: 90, hidden: true },      //工号             
                //   	                               {name: 'UserName', index: 'UserName', width: 80, hidden: true },      //姓名
                //   	                               {name: 'DepartName', index: 'DepartName', width: 80, hidden: true }, //部门
                //   	                               {name: 'Sex', index: 'Sex', width: 50, hidden: true },               //性别
                //   	                               {name: 'BirthDay', index: 'BirthDay', width: 80, hidden: true },     //生日
                //   	                               {name: 'Age', index: 'Age', width: 50, sort: false, hidden: true },  //年龄
                //   	                               {name: 'Education', index: 'Education', width: 70, hidden: true },   //学历
                //   	                               {name: 'Position', index: 'Position', width: 80, hidden: true },     //职称
                //   	                               {name: 'EmpLevel', index: 'EmpLevel', width: 90, hidden: true },     //职级
                //   	                               {name: 'IDNo', index: 'IDNo', width: 220, hidden: true },            //证件号
                //   	                               {name: 'ComeDate', index: 'ComeDate', width: 120, hidden: true },    //到职日期
                //   	                               {name: 'ConBegin', index: 'ConBegin', width: 120, hidden: true },    //合同订起
                //   	                               {name: 'ConEnd', index: 'ConEnd', width: 120, hidden: true },        //合同订结
                //   	                               {name: 'FundCode', index: 'FundCode', width: 150, hidden: true },    //公积金
                //   	                               {name: 'RoleName', index: 'RoleName', width: 250, sort: false, hidden: true },    //角色
                //   	                               {name: 'Status', index: 'Status', width: 250, sort: false, hidden: true}    //状态
                //   	                               ],
                //                        multiselect: false,
                //                        rowNum: 30,
                //                        pager: '#jqPageBirthday',
                //                        sortname: 'UserId',
                //                        viewrecords: true,
                //                        sortorder: "desc",
                //                        onSelectRow: function(id) {
                //                            $("#hidSelectedUser").val(id);
                //                        }
                //                    });
                //                    jQuery("#jqGridBirthday").jqGrid('navGrid', '#jqPageBirthday', { edit: false, add: false, del: false, search: false, refresh: false });
                //                    TableColShow();

                //新增人员
                $('#divPopUpUserInfo').jqm().jqDrag('.jqDrag');
                //人事变动
                $('#divPopUpChgPersonnel').jqm().jqDrag('.jqDrag');
                //人事档案
                $("#div_Archives").jqm().jqDrag('.jqDrag');
                //编辑人员
                $("#div_edit").jqm().jqDrag('.jqDrag');
                //职权设定
                $("#div_terms").jqm().jqDrag('.jqDrag');
                //添加虚账号
                $("#div_addVirtual").jqm().jqDrag('.jqDrag');
                //职权职务设定
                $("#div_pt").jqm().jqDrag('.jqDrag');



                //用户类型
                var optUserType = {
                    containerId: '#divUserType',
                    items: [{ txt: '请选择', val: '0'}],
                    defVal: '0',
                    showMode: 'single'
                }
                selUserType = new Selector(optUserType);

                /*
                //证件类型
                var optIDType = {
                    containerId: '#divIDType',
                    items: [{ txt: '请选择', val: '0' }, { txt: '身份证', val: '1'}],
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                }
                selIDType = new Selector(optIDType);
                */
                
                //证件类型(编辑)
                var optIDType_edit = {
                    containerId: '#edit_papers',
                    items: [{ txt: '请选择', val: '0' }, { txt: '身份证', val: '1'}],
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                }
                selPapers = new Selector(optIDType_edit);


                function initSelNull(initID, sel) {
                    var opt = {
                        containerId: '#' + initID + '',
                        items: [{ txt: '请选择', val: '0'}],
                        defVal: '0',
                        tbxWidth: 90,
                        showMode: 'single'
                    };
                    sel = new Selector(opt);
                    sel._val = "0";
                }
                /*
                //城市
                var optCity = {
                    containerId: '#divCity',
                    items: eval("([" + lsRetData[3] + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single',
                    onSelected: function() {
                        initSelNull("divCompany", selCompany);
                        $.ajax({
                            type: "get",
                            url: "service/organizationManage.ashx?op=getSel",
                            data: "cityid=" + selCity._val,
                            dataType: "text",
                            success: function(msg) {
                                var opt = {
                                    containerId: '#divCompany',
                                    items: eval("([{txt:'请选择',val:'0'}" + msg + "])"),
                                    defVal: '0',
                                    tbxWidth: 90,
                                    showMode: 'single',
                                    onSelected: function() {
                                        $("#divDepartId").unbind();
                                        //所属部门
                                        $('#divDepartId').autocomplete({
                                            deferRequestBy: 5,
                                            serviceUrl: 'service/autocomplete.ashx?companyid=' + selCompany._val,
                                            onSelect: function(value, data) {
                                                selDepart = data;
                                            }
                                        });

                                        $("#divDepartId").formValidator({
                                            onshow: "请输入所属门店！", onfocus: "请输入所属门店", oncorrect: " "
                                        }).inputValidator({
                                            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "所属门店不能为空!" }, onerror: "所属门店不能为空!"
                                        });
                                    }
                                };
                                selCompany = new Selector(opt);
                            }
                        });
                    }
                };
                selCity = new Selector(optCity);

                //教育程度
                var optEducation = {
                    containerId: '#divEducation',
                    items: [{ txt: '请选择', val: '0' },
                                { txt: '博士', val: '博士' },
                                { txt: '研究生', val: '研究生' },
                                { txt: '大学本科', val: '大学本科' },
                                { txt: '大学专科', val: '大学专科' },
                                { txt: '高中', val: '高中' },
                                { txt: '初中', val: '初中' },
                                { txt: '中专', val: '中专'}],
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selEducation = new Selector(optEducation);
                
                
                //教育（编辑）
                var optEd = {
                    containerId: '#edit_ed',
                    items: [{ txt: '请选择', val: '0' },
                                { txt: '博士', val: '博士' },
                                { txt: '研究生', val: '研究生' },
                                { txt: '大学本科', val: '大学本科' },
                                { txt: '大学专科', val: '大学专科' },
                                { txt: '高中', val: '高中' },
                                { txt: '初中', val: '初中' },
                                { txt: '中专', val: '中专'}],
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selEd_edit = new Selector(optEd);*/

                //所属公司
                //initSelNull("divCompany", selCompany);

                /*
                //职务下拉框属性
                var optEditPosition = {
                    containerId: '#divEditPosition',
                    items: eval("([" + lsRetData[4] + "])"),
                    defVal: '0',
                    colNum: '4',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selEditPosition = new Selector(optEditPosition);
                
                
                //职务下拉框属性
                var optEmpLevel = {
                    containerId: '#divEmpLevel',
                    items: eval("([" + lsRetData[5] + "])"),
                    defVal: '0',
                    colNum: '4',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selEmpLevel = new Selector(optEmpLevel);
                */
                
                //职务下拉框属性（人事变动）
                var optEmpLevel_chg = {
                    containerId: '#chg_divzd',
                    items: eval("([" + lsRetData[5] + "])"),
                    defVal: '0',
                    colNum: '4',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                chgLevel = new Selector(optEmpLevel_chg);


                //人事变动——城市
                var optCity_chg = {
                    containerId: '#chg_city',
                    items: eval("([" + lsRetData[3] + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single',
                    onSelected: function() {
                        initSelNull("chg_company", selCompany_chg);
                        $.ajax({
                            type: "get",
                            url: "service/organizationManage.ashx?op=getSel",
                            data: "cityid=" + selCity_chg._val,
                            dataType: "text",
                            success: function(msg) {
                                var opt = {
                                    containerId: '#chg_company',
                                    items: eval("([{txt:'请选择',val:'0'}" + msg + "])"),
                                    defVal: '0',
                                    tbxWidth: 90,
                                    showMode: 'single',
                                    onSelected: function() {
                                        $("#chg_depid").unbind();
                                        //所属部门
                                        $('#chg_depid').autocomplete({
                                            deferRequestBy: 5,
                                            serviceUrl: 'service/autocomplete.ashx?companyid=' + selCompany_chg._val,
                                            onSelect: function(value, data) {
                                                selDepart_chg = data;
                                            }
                                        });

                                        $("#chg_depid").formValidator({ validatorgroup: "3",
                                            onshow: "请输入变动门店", onfocus: "请输入变动门店", oncorrect: " "
                                        }).inputValidator({
                                            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "变动门店不能为空!" }, onerror: "变动门店不能为空!"
                                        });
                                    }
                                };
                                selCompany_chg = new Selector(opt);
                            }
                        });
                    }
                };
                selCity_chg = new Selector(optCity_chg);

                //人事变动——公司
                initSelNull("chg_company", selCompany_chg);

                //人事变动——变动类型
                var optType_chg = {
                    containerId: '#chg_divtype',
                    items: [{ txt: '请选择', val: '0' },
                                { txt: '离职', val: '1' },
                                { txt: '提升', val: '2' },
                                { txt: '降级', val: '3' },
                                { txt: '调动', val: '4' },
                                { txt: '调动提升', val: '5' },
                                { txt: '调动降级', val: '6' },
                                { txt: '退休', val: '7' }
                                ],
                    defVal: '0',
                    showMode: 'single',
                    tbxWidth: 90,
                    onSelected: function() {
                        if (parseInt(chgtype._val) > 3 && parseInt(chgtype._val) < 7) {
                            $("#chg_depid").unFormValidator(false);
                        }
                        else {
                            $("#chg_depid").unFormValidator(true);
                        }
                        if (parseInt(chgtype._val) != "1" && parseInt(chgtype._val) != "4" && parseInt(chgtype._val) != "7" && parseInt(chgtype._val) != "0") {
                            $("#chg_divzd").attr("class", "SelectWrapSingle validator");
                            $("#chg_divzw").attr("class", "SelectWrapSingle validator");
                            $("#tr_zd").show();
                            $("#tr_zw").show();
                        }
                        else {
                            $("#chg_divzd").attr("class", "SelectWrapSingle ");
                            $("#chg_divzw").attr("class", "SelectWrapSingle ");
                            $("#tr_zd").hide();
                            $("#tr_zw").hide();
                        }
                    }
                };
                chgtype = new Selector(optType_chg);


                //职权——城市
                var optCity_terms = {
                    containerId: '#terms_city',
                    items: eval("([" + lsRetData[3] + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single',
                    onSelected: function() {
                        initSelNull("terms_company", selCompany_terms);
                        $.ajax({
                            type: "get",
                            url: "service/organizationManage.ashx?op=getSel",
                            data: "cityid=" + selCity_terms._val,
                            dataType: "text",
                            success: function(msg) {
                                var opt = {
                                    containerId: '#terms_company',
                                    items: eval("([{txt:'请选择',val:'0'}" + msg + "])"),
                                    defVal: '0',
                                    tbxWidth: 90,
                                    showMode: 'single',
                                    onSelected: function() {
                                        $("#terms_dep").unbind();
                                        //职权——部门
                                        $('#terms_dep').autocomplete({
                                            deferRequestBy: 5,
                                            serviceUrl: 'service/autocomplete.ashx?companyid=' + selCompany_terms._val,
                                            onSelect: function(value, data) {
                                                selDepart_terms = data;
                                            }
                                        });
                                    }
                                };
                                selCompany_terms = new Selector(opt);
                            }
                        });
                    }
                };
                selCity_terms = new Selector(optCity_terms);



                //职权——公司
                initSelNull("terms_company", selCompany_terms);

                //职权
                var terms_data = "";
                $(aDataSet).each(function(i, n) {
                    if (n[2] == "1") {
                        terms_data += ",{txt:'" + n[1] + "',val:'" + (parseInt(i) + 1) + "'}";
                    }
                });

                var opt_terms = {
                    containerId: '#terms_sel',
                    items: eval("([{txt:'请选择',val:'0'}" + terms_data + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selTerms = new Selector(opt_terms);


                //职权-职务职权（查询）
                var opt_terms_s = {
                    containerId: '#pt_terms_s',
                    items: eval("([{txt:'请选择',val:'0'}" + terms_data + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selTerms_s = new Selector(opt_terms_s);

                //职权-职务职权（新增）
                var opt_terms_a = {
                    containerId: '#pt_terms_a',
                    items: eval("([{txt:'请选择',val:'0'}" + terms_data + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single'
                };
                selTerms_a = new Selector(opt_terms_a);


                //公司-职务职权
                $.ajax({
                    type: "get",
                    url: "service/userManage.ashx?op=GetAllCompany",
                    dataType: "text",
                    success: function(msg) {
                        //查询-公司
                        var opt_s = {
                            containerId: '#pt_company_s',
                            items: eval("([{txt:'请选择',val:'0'}" + msg + "])"),
                            defVal: '0',
                            tbxWidth: 90,
                            showMode: 'single'
                        }
                        selCompany_s = new Selector(opt_s);

                        //新增-公司
                        var opt_a = {
                            containerId: '#pt_company_a',
                            items: eval("([{txt:'请选择',val:'0'}" + msg + "])"),
                            defVal: '0',
                            tbxWidth: 90,
                            showMode: 'single',
                            onSelected: function() {
                                $.ajax({
                                    type: "get",
                                    url: "service/userManage.ashx?op=GetTerms",
                                    data: "companyid=" + selCompany_a._val,
                                    dataType: "text",
                                    success: function(msg) {
                                        if (msg.length > 0) {
                                            var opt = {
                                                containerId: '#pt_position_a',
                                                items: eval("([" + msg + "])"),
                                                defVal: '0',
                                                tbxWidth: 150,
                                                showMode: 'multi',
                                                colNum: 5
                                            }
                                            var sel = new Selector(opt);
                                            $("#pt_position_a h6").text("");
                                        }
                                        else {
                                            initSelNull("pt_position_a", "")
                                        }
                                    }
                                });
                            }
                        }
                        selCompany_a = new Selector(opt_a);
                    }
                });

                //虚账号——城市
                var optCity_vir = {
                    containerId: '#Virtual_city',
                    items: eval("([" + lsRetData[3] + "])"),
                    defVal: '0',
                    tbxWidth: 90,
                    showMode: 'single',
                    onSelected: function() {
                        initSelNull("Virtual_company", selCompany_Virtual);
                        selDepart_Virtual = "";
                        $("#Virtual_dep").val("");

                        $.ajax({
                            type: "get",
                            url: "service/organizationManage.ashx?op=getSel",
                            data: "cityid=" + selCity_Virtual._val,
                            dataType: "text",
                            success: function(msg) {
                                var opt = {
                                    containerId: '#Virtual_company',
                                    items: eval("([{txt:'请选择',val:'0'}" + msg + "])"),
                                    defVal: '0',
                                    tbxWidth: 90,
                                    showMode: 'single',
                                    onSelected: function() {
                                        selDepart_Virtual = "";
                                        $("#Virtual_dep").val("");

                                        $("#Virtual_dep").unbind();
                                        //所属部门
                                        $('#Virtual_dep').autocomplete({
                                            deferRequestBy: 5,
                                            serviceUrl: 'service/autocomplete.ashx?companyid=' + selCompany_Virtual._val,
                                            onSelect: function(value, data) {
                                                selDepart_Virtual = data;
                                            }
                                        });

                                        $("#Virtual_dep").formValidator({ validatorgroup: "4",
                                            onshow: "请输入所属部门", onfocus: "请输入所属部门", oncorrect: " "
                                        }).inputValidator({
                                            min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "部门不能为空!" }, onerror: "部门不能为空!"
                                        });
                                    }
                                };
                                selCompany_Virtual = new Selector(opt);
                            }
                        });
                    }
                };
                selCity_Virtual = new Selector(optCity_vir);

                //虚账号——公司
                initSelNull("Virtual_company", selCompany_Virtual);

                
                /***********************************************************Form验证*****************************************************/
                /*
                //初始化验证（人员添加）
                $.formValidator.initConfig({ formid: "formChgPersonnerl", onerror: function(msg) { alert(msg) }, onsuccess: function() { return true; } });
                //验证手机号
                $("#Mobile").functionValidator({ //手机号验证
                    fun: function(val, elem) { return val.isMobile(); }, onerror: "请输入正确的手机号"
                });
                //                    $("#UserCode").formValidator({
                //                        onshow: "请输入用户工号！", onfocus: "请输入用户工号", oncorrect: " "
                //                    }).inputValidator({
                //                        min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "工号不能为空!" }, onerror: "工号不能为空!"
                //                    });

                //证件号码验证
                $("#IDNo").formValidator({
                    onshow: "请输入证件号", onfocus: "请输入证件号", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "证件号不能为空!" }, onerror: "证件号不能为空!"
                }).regexValidator({
                    regexp: "idcard",
                    datatype: "enum",
                    onerror: "格式不正确"
                });

                $("#UserName").formValidator({
                    onshow: "请输入用户名！", onfocus: "请输入用户名", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "用户名不能为空!" }, onerror: "用户名不能为空!"
                });
                $("#divDepartId").formValidator({
                    onshow: "请输入所属门店！", onfocus: "请输入所属门店", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "所属门店不能为空!" }, onerror: "所属门店不能为空!"
                });


                $("#Address").formValidator({
                    onshow: "请输入地址", onfocus: "请输入地址", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "地址不能为空!" }, onerror: "地址不能为空!"
                });
                $("#ComeDate").formValidator({
                    onshow: "请选择到职日期", onfocus: "请选择到职日期", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "到职日期不能为空!" }, onerror: "到职日期不能为空!"
                });
                $("#OfficeTel").formValidator({
                    onshow: " ",
                    onfocus: "电话号码-分机号",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "telOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });
                $("#HomeTel").formValidator({
                    onshow: " ",
                    onfocus: "电话号码-分机号",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "telOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });

                $("#Mobile").formValidator({
                    onshow: " ",
                    onfocus: " ",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "mobileOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });
                $("#Email").formValidator({
                    onshow: " ",
                    onfocus: " ",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "emailOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });
                


                //初始化验证(人员编辑)
                $.formValidator.initConfig({ validatorgroup: "2", formid: "form_edit", onerror: function(msg) { alert(msg) }, onsuccess: function() { return true; } });
                //证件号码验证
                $("#txtIDNO").formValidator({ validatorgroup: "2",
                    onshow: "请输入证件号", onfocus: "请输入证件号", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "证件号不能为空!" }, onerror: "证件号不能为空!"
                }).regexValidator({
                    regexp: "idcard",
                    datatype: "enum",
                    onerror: "格式不正确"
                });
                $("#txtName").formValidator({ validatorgroup: "2",
                    onshow: "请输入用户名！", onfocus: "请输入用户名", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "用户名不能为空!" }, onerror: "用户名不能为空!"
                });
                $("#txtAddress").formValidator({ validatorgroup: "2",
                    onshow: "请输入地址", onfocus: "请输入地址", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "地址不能为空!" }, onerror: "地址不能为空!"
                });
                $("#txtOfficeTel").formValidator({ validatorgroup: "2",
                    onshow: " ",
                    onfocus: "电话号码-分机号",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "telOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });
                $("#txtHomeTel").formValidator({ validatorgroup: "2",
                    onshow: " ",
                    onfocus: "电话号码-分机号",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "telOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });

                $("#txtMobile").formValidator({ validatorgroup: "2",
                    onshow: " ",
                    onfocus: " ",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "mobileOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });
                $("#txtEmail").formValidator({ validatorgroup: "2",
                    onshow: " ",
                    onfocus: " ",
                    oncorrect: " "
                }).regexValidator({
                    regexp: "emailOrNull",
                    datatype: "enum",
                    onerror: "格式不正确"
                });

                //初始化验证(人员变动)
                $.formValidator.initConfig({ validatorgroup: "3", formid: "form_chg", onerror: function(msg) { alert(msg) }, onsuccess: function() { return true; } });

                $("#chg_date").formValidator({ validatorgroup: "3",
                    onshow: "请选择变动日期", onfocus: "请选择变动日期", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "变动日期不能为空!" }, onerror: "变动日期不能为空!"
                });
                $("#chg_depid").formValidator({ validatorgroup: "3",
                    onshow: "请输入变动门店", onfocus: "请输入变动门店", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "变动门店不能为空!" }, onerror: "变动门店不能为空!"
                });

                //初始化验证(虚账号)
                $.formValidator.initConfig({ validatorgroup: "4", formid: "form_Virtual", onerror: function(msg) { alert(msg) }, onsuccess: function() { return true; } });

                $("#Virtual_name").formValidator({ validatorgroup: "4",
                    onshow: "请输入虚账号姓名", onfocus: "请输入虚账号姓名", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "姓名不能为空!" }, onerror: "姓名不能为空!"
                });
                $("#Virtual_dep").formValidator({ validatorgroup: "4",
                    onshow: "请输入所属部门", onfocus: "请输入所属部门", oncorrect: " "
                }).inputValidator({
                    min: 1, empty: { leftempty: false, rightempty: false, emptyerror: "部门不能为空!" }, onerror: "部门不能为空!"
                });
                */

            } else {
                //后台处理的错误信息
                var strErrMsg = "错误信息：" + jsonRet.Data;
                alert(strErrMsg);
            }
        }
    });


    //条件输入框匹配
    $("#txtCondition").live("keyup", function() {

        var strCondition = $("#txtCondition").val();
        if (strCondition == "") {
            $("#hidConditionType").val("");
            $("#hidConditionId").val("");
            return false;
        }
        $.ajax({
            type: "POST",
            url: "service/userManage.ashx?op=GetCondition&query=" + strCondition,
            dataType: "Json",
            success: function(strRet) {
                var jsonRet = eval("(" + strRet + ")");
                if (jsonRet.RetFlg == "SUCCESS") {
                    var strHtml = jsonRet.Data;
                    $("#dlSearchMatch").html(strHtml);
                } else {
                    //后台处理的错误信息
                    var strErrMsg = "错误信息：" + jsonRet.Data;
                    alert(strErrMsg);
                }
            }
        });

        $("#dlSearchMatch").show();
    });

    $("#dlSearchMatch").live("click", function(event) {
        if (event.target.tagName == "A") {
            var objParent = $(event.target).parent();
            $("#txtCondition").val($(objParent).find("input[name='hidNm']").val());
            //$("#hidConditionType").val($(objParent).parents("dl:first").find("input[name='hidType']").val());
            $("#hidConditionType").val($(objParent).find("input[name='hidType']").val());
            $("#hidConditionId").val($(objParent).find("input[name='hidId']").val());
        }
    });

    //非空验证事件
    function validate(obj) {

        var isValidate = true;

        $.each($("#" + obj + " .validator"), function() {
            if ($(this).find("h6").text() == "请选择") {
                alert($(this).attr("name") + "不能为空");
                isValidate = false;

                return false;
            }
        });
        return isValidate
    }

    //检索领域的伸缩
    $(".btn-slide").live("click", function() {
        $("#panel").slideToggle("slow");
        $(this).toggleClass("active2"); return false;
    });

    //人员搜索
//    $("#btSreachUserInfo").live("click", function() {
//        //条件
//        var strCondition = $("#txtCondition").val();
//        //工号
//        var strUserCode = $("#txtUserCode").val();
//        //状态
//        var strStatus = selStatus.getValue();
//        //到职时间（开始）
//        var strComeDateFrom = $("#txtComeDateFrom").val();
//        //到职时间（结束）
//        var strComeDateTo = $("#txtComeDateTo").val();
//        //合同时间（开始）
//        var strContractDateFrom = $("#txtContractDateFrom").val();
//        //合同时间（结束）
//        var strContractDateTo = $("#txtContractDateTo").val();
//        //离职时间（开始）
//        var strLeaveDateFrom = $("#txtLeaveDateFrom").val();
//        //离职时间（结束）
//        var strLeaveDateTo = $("#txtLeaveDateTo").val();
//        //身份证
//        var strIDNo = $("#txtIDNo_s").val();
//        //角色
//        var strRoleId = selRole.getValue();
//        //职位
//        var strPosition = selPosition.getValue();
//        //虚账号
//        var strIsVirtual = selIsVirtual.getValue();

//        var strConditionId = $("#hidConditionId").val();
//        var strConditionType = $("#hidConditionType").val();

//        //参数列表
//        var strParams = {};

//        strParams.Condition = strCondition;
//        strParams.UserCode = strUserCode;
//        strParams.Status = strStatus;
//        strParams.ComeDateFrom = strComeDateFrom;
//        strParams.ComeDateTo = strComeDateTo;
//        strParams.ContractDateFrom = strContractDateFrom;
//        strParams.ContractDateTo = strContractDateTo;
//        strParams.LeaveDateFrom = strLeaveDateFrom;
//        strParams.LeaveDateTo = strLeaveDateTo;
//        strParams.IDNo = strIDNo;
//        strParams.RoleId = strRoleId;
//        strParams.Position = encodeURIComponent(strPosition);
//        strParams.ConditionId = strConditionId;
//        strParams.ConditionType = strConditionType;
//        strParams.IsVirtual = strIsVirtual;
//        strParams.ShowType = $("#showtype").val();

//        strParams.cityid = favorMgr.search.combl.city.getValue() == "请选择" ? "" : favorMgr.search.combl.city.getValue();
//        strParams.companyid = favorMgr.search.combl.company.getValue() == "请选择" ? "" : favorMgr.search.combl.company.getValue();
//        strParams.areaid = favorMgr.search.combl.businessDistrict.getValue()== "请选择" ? "" :favorMgr.search.combl.businessDistrict.getValue();
//        strParams.departid = favorMgr.search.combl.departs.getValue()== "请选择" ? "" :favorMgr.search.combl.departs.getValue();
//        strParams.userid = favorMgr.search.combl.emp.getValue() == "请选择" ? "" : favorMgr.search.combl.emp.getValue();

//        $("#searchstr").val(strParams.toString());
//        $("#hidSelectedUser").val("");
//        favorMgr.reloadGrid(strParams);
//        //$("#jqGridBirthday").jqGrid('setGridParam', { url: 'service/userManage.ashx?op=Search&' + strParams }).trigger("reloadGrid");

//    });




    //人员添加提交按钮事件
    $("#aSubmitAddUser").live("click", function() {

        //下拉DIV层验证
        var comboArray = [{
            objId: 'divCity',
            objTipId: 'CityTip'
        }, {
            objId: 'divDepartId',
            objTipId: 'DepartIdTip'
        }, {
            objId: 'divEmpLevel',
            objTipId: 'EmpLevelTip'
        }, {
            objId: 'divEditPosition',
            objTipId: 'EditPositionTip'
        }, {
            objId: 'divIDType',
            objTipId: 'IDTypeTip'
        }, {
            objId: 'divCompany',
            objTipId: 'CompanyTip'
}];
            //            if (!validatorDivCombo(comboArray)) {
            //                return false;
            //            }

            //表单验证
            if (!jQuery.formValidator.pageIsValid('1')) {
                return false;
            }
            if (!validate("divPopUpUserInfo"))
                return false;

            var data = {};
            data.UserName = $("#UserName").val(); 				//姓名
            //   data.UserCode = $("#UserCode").val(); 				//工号，编辑时不可编辑，添加时自动生成
            data.Sex = getRadioValueByName('input_sex'); 		//性别
            data.UserType = selUserType.getValue(); 			//用户类型
            data.IDType = $("#divIDType h6").text(); 			//证件类型
            data.IDNo = $("#IDNo").val(); 						//证件号
            data.Mobile = $("#Mobile").val(); 					//手机号
            data.HomeTel = $("#HomeTel").val(); 				//家庭电话
            data.OfficeTel = $("#OfficeTel").val(); 			//办公电话
            data.Address = $("#Address").val(); 				//家庭住址
            data.City = selCity._val; 							//所属城市ID
            data.CityName = selCity._txt; 						//所属城市
            data.CompanyId = selCompany._val; 					//所属城市
            data.CompanyName = selCompany._txt; 				//所属城市ID
            data.BirthDay = $("#BirthDay").val(); 				//生日
            data.Education = selEducation._val; 				//教育程度
            data.DepartId = selDepart; 					        //所属部门ID
            data.DepartName = $("#divDepartId").val(); 		    //所属部门
            data.BankNo = $("#BankNo").val(); 					//工资帐号
            data.ComeDate = $("#ComeDate").val(); 				//到职日期
            data.Position = selEditPosition._val; 				//职务
            data.EmpLevel = selEmpLevel._val; 					//职级
            data.FundCode = $("#FundCode").val(); 				//公积金账号
            //data.Validate=$("#Validate").attr("checked")+'';	//是否冻结
            data.Remark = $("#Remark").val(); 					//备注
            data.ConBegin = $("#ConBegin").val(); 				//合同起始日
            data.ConEnd = $("#ConEnd").val(); 					//合同终结日
            data.Email = $("#Email").val();                     //邮箱
            data.WorkBegin = $("#WorkBegin").val();             //工龄起始日

            //操作类型
            var strop = $("#hidop").val();
            if (strop == "Add") {
                strUrl = "service/userManage.ashx?op=Add";
            } else {
                //用户Id
                var strUserId = $("#hidSelectedUser").val();
                //strParams = strParams + "&UserId=" + strUserId;
                strUrl = "service/userManage.ashx?op=Edit&UserId=" + strUserId;
            }

            //AJAX通信，提交数据
            $.ajax({
                type: "POST",
                url: strUrl,
                dataType: "json",
                data: data,
                success: function(strRet) {
                    //成功
                    if (strRet.success == "1") {
                        var msg = "提交成功!\n工号：" + strRet.usercode + "";
                        if (strRet.setting != "n")
                            msg += "\n此人为高级管理者，请进行职权设置！！如不设，所有后果由操作员负责！";
                        alert(msg);
                        $("#btSreachUserInfo").click();
                    } else {
                        var strErrMsg = strRet.txt;
                        alert(strErrMsg);
                    }
                }
            });
            $("#aCloseAddUser").trigger("click");

        });

        //人员添加关闭按钮事件
        $("#aCloseAddUser").live("click", function() {

            //弹出层隐藏
            $("#divPopUpUserInfo").jqmHide();

            //工号
            $("#UserCode").attr("value", "");
            //姓名
            $("#UserName").attr("value", "");
            //性别
            //selSex.setValue("2");
            //用户类型
            //selUserType.setValue("0");
            //证件类型
            $("#divIDType h6").text("请选择");
            //证件号码
            $("#IDNo").attr("value", "");
            //手机号
            $("#Mobile").attr("value", "");
            //家庭电话
            $("#HomeTel").attr("value", "");
            //联系地址
            $("#Address").attr("value", "");
            //用户Id
            $("#hidSelectedUser").attr("value", "");
            //城市
            selCity.setValue("0");
            //公司
            //selCompany.setValue("0");
            //出生年月
            $("#BirthDay").val("");
            //教育程度
            selEducation.setValue("0");
            //所属部门
            selDepart = "";
            $("#divDepartId").val("");
            //工作电话
            $("#OfficeTel").val("");
            //工资账号
            $("#BankNo").val("");
            //到职日期
            $("#ComeDate").val("");
            //公积金账户
            $("#FundCode").val("");
            //职务
            selEditPosition.setValue("0");
            //职级
            selEmpLevel.setValue("0");
            $("#WorkBegin").val("");
            //是否冻结
            // $("#Validate").attr("checked", false);
            //备注信息
            $("#Remark").val("");


            $("#ConBegin").val("");
            $("#ConEnd").val("");

            //操作类型隐藏控件
            $("#hidop").val("");

        });

        //翻页的参数设定
        var optionsTrace = {
            items_per_page: 10,
            callback: pageselectCallback
        };

        //翻页事件
        function pageselectCallback(page_id, jq) {
            var tbody = ""; //声明表格中body部分
            $.ajax({ //这里使用到Jquery的ajax方法，具体使用在这里不详细叙述
                type: "get",
                dataType: "text",
                url: "service/userManage.ashx?op=pageShow",
                data: "pageIndex=" + page_id + "&pageRow=10&UserId=" + $("#hidSelectedUser").val(),
                //下面的操作就是成功返回数据以后，进行数据的绑定
                success: function(data) {

                    if (data == "") return;

                    $("#Archives_table tr:gt(0)").remove();

                    tbody = data;

                    $("#Archives_table").append(tbody);
                }
            });
        }
        /*
        //档案查看        
        $("#aArchives").live("click", function() {
            var strUserId = $("#hidSelectedUser").val();
            if (strUserId == "") {
                alert("请选择一行后查看档案");
                return false;
            }
            window.open("PersonnelFile.aspx?userid=" + strUserId);

        });


        //人员添加
        $("#aAddUser").live("click", function() {
            $.formValidator.resetTipState("1");
            //操作类型隐藏控件
            $("#hidop").val("Add");
            //弹出层显示
            $("#divPopUpUserInfo").jqmShow();

            $('#span_title').html('人员添加');
        });

        
        //人员基本信息编辑
        $("#aEditBaseInfo").live("click", function() {

            // $.formValidator.resetTipState("2");
            //被选择的行
            var strUserId = $("#hidSelectedUser").val();
            if (strUserId == "") {
                alert("请选择一行后进行编辑");
                return false;
            }

            var rowdata = getdatabyrowid();
            if (rowdata.Status == "-1") {
                alert("该员工已离职，不可编辑信息");
                return false;
            }

            //得到当前用户信息
            $.ajax({
                type: "POST",
                url: "service/userManage.ashx?op=GetBaseInfo&UserId=" + strUserId,
                dataType: "json",
                success: function(strRet) {
                    //成功
                    if (strRet.RetFlg == "SUCCESS") {
                        var UserInfo = strRet.Data;

                        //姓名
                        $("#txtName").attr("value", UserInfo._username);
                        //性别
                        //selSex.setValue(UserInfo._sex);
                        $("#form_edit :radio[name='input_sex'][value='" + UserInfo._sex + "']").attr("checked", true);
                        //setRadioValueByName('input_sex', UserInfo._sex)
                        //教育程度
                        selEd_edit.setValue(UserInfo._education);

                        //用户类型
                        //selUserType.setValue(UserInfo._usertype);
                        //证件类型
                        //selPapers.setValue(UserInfo._idtype);
                        $("#edit_papers h6").text(UserInfo._idtype);
                        //证件号码
                        $("#txtIDNO").attr("value", UserInfo._idno);
                        //手机号
                        $("#txtMobile").attr("value", UserInfo._mobile);
                        //家庭电话
                        $("#txtHomeTel").attr("value", UserInfo._hometel);
                        //联系地址
                        $("#txtAddress").attr("value", UserInfo._address);
                        //email
                        $("#txtEmail").attr("value", UserInfo._email);
                        //是否冻结
                        $("#form_edit :radio[name='Validate'][value='" + UserInfo._validate + "']").attr("checked", true);

                        var strBirthDay = UserInfo._birthday;
                        if (strBirthDay != null & strBirthDay != "") {
                            strBirthDay = strBirthDay.substr(1, strBirthDay.length - 2);
                            strBirthDay = "new " + strBirthDay;
                            var objBirthDay = eval(strBirthDay);
                            var strShowBirthDay = objBirthDay.getFullYear() + "-" + (objBirthDay.getMonth() + 1).toString() + "-" + objBirthDay.getDate();
                        }
                        //出生年月
                        $("#txtBirthDay").val(strShowBirthDay);

                        //教育程度
                        if (UserInfo._education.length < 1) {
                            $("#edit_ed h6").text("请选择");
                        }
                        else {
                            selEd_edit.setValue(UserInfo._education);
                        }

                        //工作电话
                        $("#txtOfficeTel").val(UserInfo._officetel);
                        //工资账号
                        $("#txtBankNo").val(UserInfo._bankno);

                        //工龄起始日
                        var strWorkBegin = UserInfo._workagebegin;
                        if (strWorkBegin != null & strConBegin != "") {
                            strWorkBegin = strWorkBegin.substr(1, strWorkBegin.length - 2);
                            strWorkBegin = "new " + strWorkBegin;
                            var objWorkBegin = eval(strWorkBegin);
                            var strShowWorkBegin = objWorkBegin.getFullYear() + "-" + (objWorkBegin.getMonth() + 1).toString() + "-" + objWorkBegin.getDate();
                        } else {
                            strShowWorkBegin = "";
                        }

                        $("#txtWorkBegin").val(strShowWorkBegin);

                        //合同起始日期
                        var strConBegin = UserInfo._conbegin;
                        if (strConBegin != null & strConBegin != "") {
                            strConBegin = strConBegin.substr(1, strConBegin.length - 2);
                            strConBegin = "new " + strConBegin;
                            var objConBegin = eval(strConBegin);
                            var strShowConBegin = objConBegin.getFullYear() + "-" + (objConBegin.getMonth() + 1).toString() + "-" + objConBegin.getDate();
                        } else {
                            strConBegin = "";
                        }

                        $("#txtConBegin").val(strShowConBegin);

                        //合同结束日期
                        var strConEnd = UserInfo._conend;
                        if (strConEnd != null & strConEnd != "") {
                            strConEnd = strConEnd.substr(1, strConEnd.length - 2);
                            strConEnd = "new " + strConEnd;
                            var objConEnd = eval(strConEnd);
                            var strShowobjConEnd = objConEnd.getFullYear() + "-" + (objConEnd.getMonth() + 1).toString() + "-" + objConEnd.getDate();
                        } else {
                            strConEnd = "";
                        }

                        $("#txtConEnd").val(strShowobjConEnd);

                        //公积金账户
                        $("#txtFundCode").val(UserInfo._fundcode);

                        //是否冻结
                        // if (UserInfo._validate == false) {
                        // $("#Validate").attr("checked", false);
                        // } else {
                        // $("#Validate").attr("checked", true);
                        // }
                        //备注信息
                        $("#txtRemark").val(UserInfo._remark);

                        //    $.formValidator.resetTipState("2");
                        //弹出层显示
                        $("#div_edit").jqmShow();

                        $('#span_edit').html('人员编辑');
                    } else {
                        var strErrMsg = jsonRet.Data;
                        alert(strErrMsg);
                    }
                }
            });

            //操作类型隐藏控件
            $("#hidop").val("Update");
        });
        */
        
        //人员编辑关闭按钮事件
        $("#aEditClose").live("click", function() {

            //弹出层隐藏
            $("#div_edit").jqmHide();

            //姓名
            $("#txtName").attr("value", "");
            //selPapers.setValue("0");
            $("#edit_papers h6").text("请选择");
            //证件号码
            $("#txtIDNO").attr("value", "");
            //手机号
            $("#txtMobile").attr("value", "");
            //家庭电话
            $("#txtHomeTel").attr("value", "");
            //联系地址
            $("#txtAddress").attr("value", "");

            //出生年月
            $("#txtBirthDay").val("");
            //教育程度
            selEd_edit.setValue("0");

            //工作电话
            $("#txtOfficeTel").val("");
            //工资账号
            $("#txtBankNo").val("");
            //到职日期
            $("#txtComeDate").val("");
            //公积金账户
            $("#txtFundCode").val("");
            //工龄起始日
            $("#txtWorkBegin").val("");
            //是否冻结
            // $("#Validate").attr("checked", false);
            //备注信息
            $("#txtRemark").val("");


            $("#txtConBegin").val("");
            $("#txtConEnd").val("");
        });

        //人员编辑提交
        $("#aEditSubmit").live("click", function() {
            if (!jQuery.formValidator.pageIsValid('2')) {
                return false;
            }
            if (!validate("form_edit"))
                return false;

            var data = {};
            data.UserName = $("#txtName").val(); 				    //姓名
            data.Sex = getRadioValueByName('input_sex'); 		    //性别
            data.IDType = $("#edit_papers h6").text(); 				//证件类型
            data.IDNo = $("#txtIDNO").val(); 						//证件号
            data.Mobile = $("#txtMobile").val(); 					//手机号
            data.HomeTel = $("#txtHomeTel").val(); 				    //家庭电话
            data.OfficeTel = $("#txtOfficeTel").val(); 			    //办公电话
            data.Address = $("#txtAddress").val(); 				    //家庭住址
            data.BirthDay = $("#txtBirthDay").val(); 				//生日
            data.Education = selEd_edit._val; 				        //教育程度
            data.BankNo = $("#txtBankNo").val(); 					//工资帐号
            data.FundCode = $("#txtFundCode").val(); 				//公积金账号
            data.Validate = $("#validate_true").attr("checked");    //是否冻结
            data.Remark = $("#txtRemark").val(); 					//备注
            data.ConBegin = $("#txtConBegin").val(); 				//合同起始日
            data.ConEnd = $("#txtConEnd").val(); 					//合同终结日
            data.Email = $("#txtEmail").val();                      //邮箱
            data.WorkBegin = $("#txtWorkBegin").val();              //工龄起始日


            //AJAX通信，提交数据
            $.ajax({
                type: "POST",
                url: "service/userManage.ashx?op=Edit&UserId=" + $("#hidSelectedUser").val(),
                dataType: "json",
                data: data,
                success: function(strRet) {
                    //成功
                    if (strRet.success == "1") {
                        alert("提交成功!");
                        $("#btSreachUserInfo").click();
                    } else {
                        var strErrMsg = strRet.txt;
                        alert(strErrMsg);
                    }
                }
            });
            $("#aEditClose").trigger("click");
        });

        /*
        //人事变动弹出层
        $("#aChgPersonnel").live("click", function() {
            var strUserId = $("#hidSelectedUser").val();
            if (strUserId == "") {
                alert("请选择一行后进行人事变动");
                return false;
            }
            var rowdata = getdatabyrowid();
            if (rowdata.Status == "-1") {
                alert("该员工已离职，不可编辑信息");
                return false;
            }
            $("#chg_code").text(rowdata.UserCode);
            $("#chg_name").text(rowdata.UserName);
            $("#chg_dep").text(rowdata.DepartName);

            $("#divPopUpChgPersonnel").jqmShow();
        });*/

        //人事变动关闭层
        $("#aChangeClose").live("click", function() {
            selCity_chg.setValue("0");
            chgtype.setValue("0");
            chgPosition.setValue("0");
            chgLevel.setValue("0");
            initSelNull("chg_company", selCompany_chg);
            $("#chg_date").val("");
            $("#chg_depid").val("");

            $("#chg_divzd").attr("class", "SelectWrapSingle ");
            $("#chg_divzw").attr("class", "SelectWrapSingle ");
            $("#tr_zd").hide();
            $("#tr_zw").hide();

            $("#chg_reason").val("");

            $("#divPopUpChgPersonnel").jqmHide();
        });


        //人事变动提交
        $("#aChangeSubmit").live("click", function() {
            if (!jQuery.formValidator.pageIsValid('3')) {
                return false;
            }
            if (!validate("divPopUpChgPersonnel"))
                return false;

            var data = {};
            data.DepName = $("#chg_depid").val(); 				                        //变动部门——名称
            data.DepId = selDepart_chg; 		                                        //变动部门——ID
            data.Type = chgtype._txt; 			                                        //变动类型
            data.TypeId = chgtype._val;                                                 //变动类型序号
            data.DTime = $("#chg_date").val();                                          //变动日期
            if ($("#chg_divzd h6").text() != "请选择")
                data.Level = $("#chg_divzd h6").text();                                 //变动职级
            if ($("#chg_divzw h6").text() != "请选择")
                data.Position = $("#chg_divzw h6").text();                               //变动职务
            data.Reason = $("#chg_reason").val();                                       //变动理由

            $.ajax({
                type: "POST",
                url: "service/userManage.ashx?op=Change&UserId=" + $("#hidSelectedUser").val(),
                data: data,
                dataType: "json",
                success: function(strRet) {
                    //成功
                    if (strRet.success == "1") {
                        var strCurUrl = jQuery('#jqGridBirthday').jqGrid('getGridParam', 'url');
                        var msg = "提交成功!";
                        if (strRet.setting != "n")
                            msg += "\n此人为高级管理者，请进行职权设置！！如不设，所有后果由操作员负责！";
                        alert(msg);
                        $("#jqGridBirthday").jqGrid('setGridParam', { url: strCurUrl }).trigger("reloadGrid");
                        $("#aChangeClose").click();
                    } else {
                        var strErrMsg = strRet.txt;
                        alert(strErrMsg);
                    }

                }
            });

        });
        /*
        //虚账号弹出层
        $("#aAddVirtual").live("click", function() {
            $("#Virtual_name").val("");
            $("#div_addVirtual").jqmShow();
        });*/

        //虚账号关闭
        $("#aVirtualClose").live("click", function() {
            $("#Virtual_name").val("");
            $("#div_addVirtual").jqmHide();
        });

        //虚账号提交
        $("#aVirtualSubmit").live("click", function() {
            if (!jQuery.formValidator.pageIsValid('4')) {
                return false;
            }

            var data = {};
            data.uname = $("#Virtual_name").val();
            data.cityid = selCity_Virtual._val;
            data.city = selCity_Virtual._txt;
            data.companyid = selCompany_Virtual._val;
            data.company = selCompany_Virtual._txt;
            data.depid = selDepart_Virtual;
            data.dep = $("#Virtual_dep").val();

            $.ajax({
                type: "POST",
                url: "service/userManage.ashx?op=Virtual",
                data: data,
                dataType: "json",
                success: function(strRet) {
                    if (strRet.success == "1") {
                        $("#aVirtualClose").click();
                        alert("添加成功！");
                    }
                    else
                        alert(strRet.txt);
                }
            });

        });


        function resetTerms() {
            selCity_terms.setValue("0");
            initSelNull("terms_company", selCompany_terms);
            selTerms.setValue("0");

            $("#terms_dep").val("");
            $("#terms_date").val("");
            // selDepart_terms = "undefined";

            $("#div_TermsShow").hide();
            $("#btn_add").hide();
            $("#btn_addshow").show();
        }

        /*
        //职权范围变更
        $("#aEditScope").live("click", function() {
            var strUserId = $("#hidSelectedUser").val();
            if (strUserId == "") {
                alert("请选择一行后查看档案");
                return false;
            }
            var rowdata = getdatabyrowid();
            if (rowdata.Status == "-1") {
                alert("该员工已离职，不可编辑信息");
                return false;
            }
            $("#terms_usercode").text(rowdata.UserCode);
            $("#terms_username").text(rowdata.UserName);

            resetTerms();

            //得到当前用户职权记录
            $.ajax({
                type: "get",
                url: "service/userManage.ashx?op=GetCount&stype=terms&UserId=" + strUserId,
                dataType: "json",
                success: function(data) {
                    $("#hidTermsCount").val(data.count);
                    $("#terms_table tr:gt(0)").remove();
                    $("#pagination_terms .white_pgToolbar").remove();
                    $("#pagination_terms").pagination(parseInt(data.count), optionsTrace_terms);
                    $("#div_terms").jqmShow();
                }
            });
        }); 
        
        //新增职权(显示)
        $("#btn_addshow").live("click", function() {
            $("#div_TermsShow").show();
            $("#btn_add").show();
            $(this).hide();
        });*/

        //新增职权（提交）
        $("#btn_add").live("click", function() {
            if ($("#terms_dep").val().length < 1 || selDepart_terms == "undefined") {
                alert("请选择门店！");
                return;
            }
            if (selTerms._val == "0") {
                alert("请选择职权！");
                return;
            }
            if ($("#terms_date").val().length < 1) {
                alert("请选择开始时间！");
                return;
            }
            else {
                var data = {};
                data.depid = selDepart_terms;
                data.depname = $("#terms_dep").val();
                data.userid = $("#hidSelectedUser").val();
                data.username = $("#terms_username").text();
                data.roletype = selTerms._val;
                data.comedate = $("#terms_date").val();

                $.ajax({
                    type: "POST",
                    url: "service/userManage.ashx?op=Terms&stype=add",
                    data: data,
                    dataType: "json",
                    success: function(strRet) {
                        //成功
                        if (strRet.success == "1") {
                            alert("提交成功！");
                            var count = $("#hidTermsCount").val();
                            count = parseInt(count) + 1;
                            $("#hidTermsCount").val(count);
                            $("#terms_table tr:gt(0)").remove();
                            $("#pagination_terms .white_pgToolbar").remove();
                            $("#pagination_terms").pagination(parseInt(count), optionsTrace_terms);
                            resetTerms();
                        } else {
                            var strErrMsg = strRet.txt;
                            alert(strErrMsg);
                        }
                    }
                });
            }
        });

        //重置职权职务层
        function resetDiv_pt() {
            selCompany_a.setValue("0");
            selCompany_s.setValue("0");
            selTerms_a.setValue("0");
            selTerms_s.setValue("0");
            initSelNull("pt_position_a", "");
        }

        //查询职权职务
        $("#pt_search").live("click", function() {
            var strwhere = "";
            if (selTerms_s._val != "0")
                strwhere += "&PostName=" + encodeURIComponent(selTerms_s._txt);
            if (selCompany_s._val != "0")
                strwhere += "&CompanyID=" + selCompany_s._val;

            $("#hidptstrwhere").val(strwhere);

            $.ajax({
                type: "get",
                url: "service/userManage.ashx",
                data: "op=GetCount&stype=pt" + strwhere,
                dataType: "json",
                success: function(msg) {
                    var count = msg.count;
                    $("#hidptCount").val(count);
                    $("#table_pt tr:gt(0)").remove();
                    $("#pagination_pt .white_pgToolbar").remove();
                    $("#pagination_pt").pagination(parseInt(count), optionsTrace_pt);
                }
            })

        });


        //弹出职权职务层
        $("#aPosTerms").live("click", function() {
            resetDiv_pt();
            $("#div_pt").jqmShow();
        });

        //提交添加职权职务关系
        $("#btn_pt_a").live("click", function() {
            if (selTerms_a._val == "0") {
                alert("请选择职权");
                return;
            }
            if (selCompany_a._val == "0") {
                alert("请选择公司");
                return;
            }
            if ($("#pt_position_a h6").text().length < 1 || $("#pt_position_a h6").text() == "请选择") {
                alert("请选择职务");
                return;
            }

            var data = {};
            data.terms = selTerms_a._txt;
            data.companyid = selCompany_a._val;
            data.pos = $("#pt_position_a h6").text().substring(0, ($("#pt_position_a h6").text().length - 1));
            data.stype = "add";

            $.ajax({
                type: "POST",
                url: "service/userManage.ashx?op=ptOperation",
                data: data,
                dataType: "json",
                success: function(msg) {
                    if (msg.success == "1") {
                        alert("操作成功");
                        selTerms_a.setValue("0");
                        selCompany_a.setValue("0");
                        initSelNull("pt_position_a", "");
                    }
                    else
                        alert(msg.txt);
                }
            });
        });

    });


/**
* 验证DIV下拉框控件
*@objId 需要验证的DIV的ID
*@objTipId 显示错误验证信息的ID
*@empValue 为空的默认值
*/
function validatorDiv(objId,objTipId,empValue){
	if(!empValue){
		empValue='请选择';
	}
	if($('#'+objId+'>h6').text()==empValue){
		$('#'+objTipId).show();
		return false;
	}else{
		$('#'+objTipId).hide();	
		return true;
	}
}
	
/**
* 多个验证DIV下拉框控件
*@objArray 需要验证的控件'ID',显示错误信息的DOM'ID',默认空值组成的数组
*@example [{
		objId:'divCity',
		objTipId:'CityTip',
		empValue:'请选择'
	}]
*/
function validatorDivCombo(objArray){
	var trueCount=0;
	for(var i=0;i<objArray.length;i++){
		if(validatorDiv(objArray[i].objId,objArray[i].objTipId,objArray[i].empValue)){
			trueCount++;
		}
	}
	if(trueCount==objArray.length){
		return true;
	}
	return false;
}

/**
* 获取同名的radio选中值
* @name radio控件的 name属性值
*/
function getRadioValueByName(name){
	var _value='';
	$('input[type="radio"][name="'+name+'"]').each(function(){
		if(this.checked){				
			_value=this.value;
			return
		}
	});
	return _value;
}

function setRadioValueByName(name,value){	
	$('input[type="radio"][name="'+name+'"]').each(function(){
		if(this.value==value){
			this.checked=true;
			return;
		}
	});
}

function initSelNull(initID, sel) {
    var opt = {
        containerId: '#' + initID + '',
        items: [{ txt: '请选择', val: '0'}],
        defVal: '0',
        tbxWidth: 90,
        showMode: 'single'
    };
    sel = new Selector(opt);
    sel._val = "0";
}

var endtime;
function del_Terms(obj) {
    if (obj == "0")
        alert("该条记录为隶属信息，不可删除！");
    else {
        if (input_endtime()) {
            $.ajax({
                type: "POST",
                url: "service/userManage.ashx?op=Terms&stype=del&recordid=" + obj + "&endtime=" + endtime,
                dataType: "json",
                success: function(strRet) {
                if (strRet.success == "1") {
                    alert("删除成功！");
                        var count = $("#hidTermsCount").val();
                        count = parseInt(count) - 1;
                        $("#hidTermsCount").val(count);
                        $("#terms_table tr:gt(0)").remove();
                        $("#pagination_terms .white_pgToolbar").remove();
                        $("#pagination_terms").pagination(parseInt(count), optionsTrace_terms);
                    }
                    else
                        alert(strRet.txt);
                }
            });
        }
    }
}

//删除职权职务
function del_pt(obj) {
    if (confirm("确定删除此条记录吗？")) {
        $.ajax({
            type: "POST",
            url: "service/userManage.ashx?op=ptOperation&stype=del&recordid=" + obj,
            dataType: "json",
            success: function(strRet) {
                if (strRet.success == "1") {
                    alert("删除成功！");
                    var count = $("#hidptCount").val();
                    count = parseInt(count) - 1;
                    $("#hidptCount").val(count);
                    $("#table_pt tr:gt(0)").remove();
                    $("#pagination_pt .white_pgToolbar").remove();
                    $("#pagination_pt").pagination(parseInt(count), optionsTrace_pt);
                }
                else
                    alert(strRet.txt);
            }
        });
    }
}

function input_endtime() {
    var danchu = window.prompt("请输入结束日期：", '');
    if (danchu != null) {
        endtime = new Date(danchu.replace(/-/, "/"))
        if (endtime == "NaN") {
            alert("结束日期输入有误！格式YYYY-MM-DD");
            return false;
        }
        else {
            endtime = danchu;
            return true;
        } 
    }
}

//翻页的参数设定（人员职权设定）
var optionsTrace_terms = {
    items_per_page: 10,
    callback: pageselectCallback_terms
};

//翻页事件（人员职权设定）
function pageselectCallback_terms(page_id, jq) {
    var tbody = ""; //声明表格中body部分
    $.ajax({ //这里使用到Jquery的ajax方法，具体使用在这里不详细叙述
        type: "get",
        dataType: "text",
        url: "service/userManage.ashx?op=pageShow",
        data: "stype=terms&pageIndex=" + page_id + "&pageRow=10&UserId=" + $("#hidSelectedUser").val(),
        //下面的操作就是成功返回数据以后，进行数据的绑定
        success: function(data) {

            if (data == "") return;

            $("#terms_table tr:gt(0)").remove();

            tbody = data;

            $("#terms_table").append(tbody);
        }
    });
}


//翻页的参数设定（职权职务设定）
var optionsTrace_pt = {
    items_per_page: 10,
    callback: pageselectCallback_pt
};

//翻页事件（职权职务设定）
function pageselectCallback_pt(page_id, jq) {
    var tbody = ""; //声明表格中body部分
    var strwhere = $("#hidptstrwhere").val();
    $.ajax({ //这里使用到Jquery的ajax方法，具体使用在这里不详细叙述
        type: "get",
        dataType: "text",
        url: "service/userManage.ashx?op=pageShow",
        data: "stype=pt&pageIndex=" + page_id + "&pageRow=10&strwhere=" + strwhere,
        //下面的操作就是成功返回数据以后，进行数据的绑定
        success: function(data) {

            if (data == "") return;

            $("#table_pt tr:gt(0)").remove();

            tbody = data;

            $("#table_pt").append(tbody);
        }
    });
}

function getdatabyrowid() {
    var rowdata = {};
    $(".selected_orgbgcolor td").each(function() {
        var colname = $(this).attr("name");
        rowdata[colname] = $(this).text();
    });
    return rowdata;
}